package cn.kailangtu.dataspot.tasks;

import android.graphics.Bitmap;
import android.os.SystemClock;
import android.util.Log;
import org.greenrobot.eventbus.EventBus;

import java.util.Random;

import cn.kailangtu.commonevents.eventEntity.DataBeanChangedEvent;
import cn.kailangtu.commonevents.eventEntity.TemperatureDataEvent;
import cn.kailangtu.commontools.AppVariable;
import cn.kailangtu.commontools.CommonUtils;
import cn.kailangtu.commontools.Loggers;
import cn.kailangtu.commontools.TemperatureImageUtils;
import cn.kailangtu.commontools.socket.TemperatureManager;
import cn.kailangtu.dataspot.data.HighData;
import cn.kailangtu.dataspot.status;
import cn.kailangtu.serialutils.api.ReceiveMsgListenerV2;
import cn.kailangtu.serialutils.modbus.modbusUtil;

public class TemperatureTask extends BaseTask{

    int[] tempData1 = new int[0x300];
    int[] tempData2 = new int[0x300];
    int[] tempData3 = new int[0x300];

    @Override
    public void init()
    {
        initCommand();

        if(AppVariable.platform_version == 450)
        {
            initSend450();
        }
        else {

        }

        drawImage();
//        new Thread(new Runnable() {
//            @Override
//            public void run() {
//                Random r= new Random();
//                while(true)
//                {
//                    for(int i = 0;i< 0x300;i=i+2)
//                    {
//                        tempData1[i] = (byte)r.nextInt(250);
//                        tempData2[i] = (byte)r.nextInt(250);
//                        tempData3[i] = (byte) r.nextInt(250);
//                        Log.d("SHOOTLEE_TETETE","1:"+tempData1[i]);
//                        Log.d("SHOOTLEE_TETETE","2:"+tempData2[i]);
//                        Log.d("SHOOTLEE_TETETE","3:"+tempData3[i]);
//                    }
//                    SystemClock.sleep(500);
//                }
//
//            }
//        }).start();
    }




    @Override
    void close() {
        isRun = false;
    }


    private void initCommand()
    {


        byte[] socket1_1 = new byte[]{0x00,0x11,0x00,0x00,0x00,0x06,0x01,0x03,0x00,(byte)0x00,0x00,(byte)0x64};
        byte[] socket1_2 = new byte[]{0x00,0x12,0x00,0x00,0x00,0x06,0x01,0x03,0x00,(byte)0x64,0x00,(byte)0x64};
        byte[] socket1_3 = new byte[]{0x00,0x13,0x00,0x00,0x00,0x06,0x01,0x03,0x00,(byte)0xC8,0x00,(byte)0x64};
        byte[] socket1_4 = new byte[]{0x00,0x14,0x00,0x00,0x00,0x06,0x01,0x03,0x01,(byte)0x2C,0x00,(byte)0x64};
        byte[] socket1_5 = new byte[]{0x00,0x15,0x00,0x00,0x00,0x06,0x01,0x03,0x01,(byte)0x90,0x00,(byte)0x64};
        byte[] socket1_6 = new byte[]{0x00,0x16,0x00,0x00,0x00,0x06,0x01,0x03,0x01,(byte)0xF4,0x00,(byte)0x64};
        byte[] socket1_7 = new byte[]{0x00,0x17,0x00,0x00,0x00,0x06,0x01,0x03,0x02,(byte)0x58,0x00,(byte)0x64};
        byte[] socket1_8 = new byte[]{0x00,0x18,0x00,0x00,0x00,0x06,0x01,0x03,0x02,(byte)0xBC,0x00,(byte)0x55};

        byte[] socket2_1 = new byte[]{0x00,0x21,0x00,0x00,0x00,0x06,0x01,0x03,0x03,(byte)0x20,0x00,(byte)0x64};
        byte[] socket2_2 = new byte[]{0x00,0x22,0x00,0x00,0x00,0x06,0x01,0x03,0x03,(byte)0x84,0x00,(byte)0x64};
        byte[] socket2_3 = new byte[]{0x00,0x23,0x00,0x00,0x00,0x06,0x01,0x03,0x03,(byte)0xE8,0x00,(byte)0x64};
        byte[] socket2_4 = new byte[]{0x00,0x24,0x00,0x00,0x00,0x06,0x01,0x03,0x04,(byte)0x4C,0x00,(byte)0x64};
        byte[] socket2_5 = new byte[]{0x00,0x25,0x00,0x00,0x00,0x06,0x01,0x03,0x04,(byte)0xB0,0x00,(byte)0x64};
        byte[] socket2_6 = new byte[]{0x00,0x26,0x00,0x00,0x00,0x06,0x01,0x03,0x05,(byte)0x14,0x00,(byte)0x64};
        byte[] socket2_7 = new byte[]{0x00,0x27,0x00,0x00,0x00,0x06,0x01,0x03,0x05,(byte)0x78,0x00,(byte)0x64};
        byte[] socket2_8 = new byte[]{0x00,0x28,0x00,0x00,0x00,0x06,0x01,0x03,0x05,(byte)0xDC,0x00,(byte)0x55};


        byte[] socket3_1 = new byte[]{0x00,0x31,0x00,0x00,0x00,0x06,0x01,0x03,0x06,(byte)0x40,0x00,(byte)0x64};
        byte[] socket3_2 = new byte[]{0x00,0x32,0x00,0x00,0x00,0x06,0x01,0x03,0x06,(byte)0xA4,0x00,(byte)0x64};
        byte[] socket3_3 = new byte[]{0x00,0x33,0x00,0x00,0x00,0x06,0x01,0x03,0x07,(byte)0x08,0x00,(byte)0x64};
        byte[] socket3_4 = new byte[]{0x00,0x34,0x00,0x00,0x00,0x06,0x01,0x03,0x07,(byte)0x6C,0x00,(byte)0x64};
        byte[] socket3_5 = new byte[]{0x00,0x35,0x00,0x00,0x00,0x06,0x01,0x03,0x07,(byte)0xD0,0x00,(byte)0x64};
        byte[] socket3_6 = new byte[]{0x00,0x36,0x00,0x00,0x00,0x06,0x01,0x03,0x08,(byte)0x34,0x00,(byte)0x64};
        byte[] socket3_7 = new byte[]{0x00,0x37,0x00,0x00,0x00,0x06,0x01,0x03,0x08,(byte)0x98,0x00,(byte)0x64};
        byte[] socket3_8 = new byte[]{0x00,0x38,0x00,0x00,0x00,0x06,0x01,0x03,0x08,(byte)0xFC,0x00,(byte)0x55};





        lsReadCom485.add(socket1_1);
        lsReadCom485.add(socket1_2);
        lsReadCom485.add(socket1_3);
        lsReadCom485.add(socket1_4);
        lsReadCom485.add(socket1_5);
        lsReadCom485.add(socket1_6);
        lsReadCom485.add(socket1_7);
        lsReadCom485.add(socket1_8);

        lsReadCom485.add(socket2_1);
        lsReadCom485.add(socket2_2);
        lsReadCom485.add(socket2_3);
        lsReadCom485.add(socket2_4);
        lsReadCom485.add(socket2_5);
        lsReadCom485.add(socket2_6);
        lsReadCom485.add(socket2_7);
        lsReadCom485.add(socket2_8);


        lsReadCom485.add(socket3_1);
        lsReadCom485.add(socket3_2);
        lsReadCom485.add(socket3_3);
        lsReadCom485.add(socket3_4);
        lsReadCom485.add(socket3_5);
        lsReadCom485.add(socket3_6);
        lsReadCom485.add(socket3_7);
        lsReadCom485.add(socket3_8);

    }


    private void initSend450()
    {
        new Thread(new Runnable() {
            @Override
            public void run() {
                SystemClock.sleep(1000);
                while (isRun) {
                    SystemClock.sleep(100);

                    if (temperatureQuere.size() > 0) {
                        byte[] currentCmd = temperatureQuere.poll();

                    } else {
                        long sendTime = System.currentTimeMillis();
                        byte[] receive =   TemperatureManager.getInstance().sendAndReceive(lsReadCom485.get(indexCom));

                        Log.e("DiffTime,temperature","Time:"+(System.currentTimeMillis() - sendTime)+"ms");
                        if(receive!= null && receive.length > 100)
                        {
                            Log.d("SHOOTLEE_SOCKET","读到数据："+CommonUtils.ByteArrayToHexString(receive));
                            if(receive[1] == 0x11)
                            {
                                copyToInt(tempData1,receive,0,9+32,84);
                                setTemperValue(1,
                                        CommonUtils.byteArrayToInt16Temp(new byte[]{receive[26+9],receive[27+9]}),
                                        CommonUtils.byteArrayToInt16Temp(new byte[]{receive[28+9],receive[29+9]}));
                            }
                            else if(receive[1] == 0x12){
                                copyToInt(tempData1,receive,84,9,100);
                            }
                            else if(receive[1] == 0x13){
                                copyToInt(tempData1,receive,184,9,100);
                            }
                            else if(receive[1] == 0x14){
                                copyToInt(tempData1,receive,284,9,100);
                            }
                            else if(receive[1] == 0x15){
                                copyToInt(tempData1,receive,384,9,100);
                            }
                            else if(receive[1] == 0x16){
                                copyToInt(tempData1,receive,484,9,100);
                            }
                            else if(receive[1] == 0x17){
                                copyToInt(tempData1,receive,584,9,100);
                            }
                            else if(receive[1] == 0x18){
                                copyToInt(tempData1,receive,684,9,84);
                            }
                            if(receive[1] == 0x21)
                            {
                                copyToInt(tempData2,receive,0,9+32,84);
                                setTemperValue(2,
                                        CommonUtils.byteArrayToInt16Temp(new byte[]{receive[26+9],receive[27+9]}),
                                        CommonUtils.byteArrayToInt16Temp(new byte[]{receive[28+9],receive[29+9]}));
                            }
                            else if(receive[1] == 0x22){
                                copyToInt(tempData2,receive,84,9,100);
                            }
                            else if(receive[1] == 0x23){
                                copyToInt(tempData2,receive,184,9,100);
                            }
                            else if(receive[1] == 0x24){
                                copyToInt(tempData2,receive,284,9,100);
                            }
                            else if(receive[1] == 0x25){
                                copyToInt(tempData2,receive,384,9,100);
                            }
                            else if(receive[1] == 0x26){
                                copyToInt(tempData2,receive,484,9,100);
                            }
                            else if(receive[1] == 0x27){
                                copyToInt(tempData2,receive,584,9,100);
                            }
                            else if(receive[1] == 0x28){
                                copyToInt(tempData2,receive,684,9,84);
                            }
                            if(receive[1] == 0x31)
                            {
                                copyToInt(tempData3,receive,0,9+32,84);
                                setTemperValue(3,
                                        CommonUtils.byteArrayToInt16Temp(new byte[]{receive[26+9],receive[27+9]}),
                                        CommonUtils.byteArrayToInt16Temp(new byte[]{receive[28+9],receive[29+9]}));
                            }
                            else if(receive[1] == 0x32){
                                copyToInt(tempData3,receive,84,9,100);
                            }
                            else if(receive[1] == 0x33){
                                copyToInt(tempData3,receive,184,9,100);
                            }
                            else if(receive[1] == 0x34){
                                copyToInt(tempData3,receive,284,9,100);
                            }
                            else if(receive[1] == 0x35){
                                copyToInt(tempData3,receive,384,9,100);
                            }
                            else if(receive[1] == 0x36){
                                copyToInt(tempData3,receive,484,9,100);
                            }
                            else if(receive[1] == 0x37){
                                copyToInt(tempData3,receive,584,9,100);
                            }
                            else if(receive[1] == 0x38){
                                copyToInt(tempData3,receive,684,9,84);
                            }

                        }
                        else{
                            Log.d("SHOOTLEE_SOCKET","未读到有效数据");
                            SystemClock.sleep(2000);
                        }
                        indexCom++;
                        if (indexCom >= lsReadCom485.size()) {
                            indexCom = 0;
                        }
                    }
                }
            }
        }).start();
    }





    private void copyToInt(int[] source,byte[] data,int sourceBegin,int dataBegin,int dataLength)
    {

        int end = sourceBegin + dataLength;
         int index = 0;
        for(int i = sourceBegin;i < end;i++){
            int dataIndex = dataBegin + index * 2;
            index ++;
            source[i] = CommonUtils.byteArrayToInt16Temp(new byte[]{data[dataIndex], data[dataIndex + 1]});
        }
    }

    private void setTemperValue(int index, int tempMax,int tempMin)
    {
        boolean hasChanged = false;
        if(index== 1)
        {
            Log.e("NEWNEWNEW","1 MAX:"+tempMax+" MIN:"+tempMin);
            status.temp_3584 = new Float(tempMax) / 10;
            status.temp_3587 = new Float(tempMin) / 10;
            status.temp_avg_1 = (status.temp_3584 + status.temp_3587) /2;
            if(HighData.getInstance().getValue(3584) != tempMax)
            {
                plcQuere.offer(modbusUtil.writeToOne(1,CommonUtils.int2ByteArray(3584),CommonUtils.int2ByteArray(tempMax)));
            }
            if(HighData.getInstance().getValue(3587) != tempMin)
            {
                plcQuere.offer(modbusUtil.writeToOne(1,CommonUtils.int2ByteArray(3587),CommonUtils.int2ByteArray(tempMin)));
            }

            if(HighData.getInstance().setAdd_single_3584(tempMax))
            {
                hasChanged = true;
            }
            if(HighData.getInstance().setAdd_single_3587(tempMin)){
                hasChanged = true;
            }
        }else if(index== 2){
            Log.e("NEWNEWNEW","2 MAX:"+tempMax+" MIN:"+tempMin);

            status.temp_3585 = new Float(tempMax) / 10;
            status.temp_3588 = new Float(tempMin) / 10;
            status.temp_avg_2 = (status.temp_3585 + status.temp_3588) /2;

            //地址为2的温度
            if(HighData.getInstance().getValue(3585) != tempMax)
            {
                plcQuere.offer(modbusUtil.writeToOne(1,CommonUtils.int2ByteArray(3585),CommonUtils.int2ByteArray(tempMax)));
            }
            if(HighData.getInstance().getValue(3588) != tempMin)
            {
                plcQuere.offer(modbusUtil.writeToOne(1,CommonUtils.int2ByteArray(3588),CommonUtils.int2ByteArray(tempMin)));
            }

            if(HighData.getInstance().setAdd_single_3585(tempMax))
            {
                hasChanged = true;
            }
            if(HighData.getInstance().setAdd_single_3588(tempMin))
            {
                hasChanged = true;
            }
        }
        else if(index == 3)
        {
            Log.e("NEWNEWNEW","3 MAX:"+tempMax+" MIN:"+tempMin);
            status.temp_3586 = new Float(tempMax) / 10;
            status.temp_3589 = new Float(tempMin) / 10;
            status.temp_avg_3 = (status.temp_3586 + status.temp_3589) /2;
            //地址为3的温度
            if(HighData.getInstance().getValue(3586) != tempMax)
            {
                plcQuere.offer(modbusUtil.writeToOne(1,CommonUtils.int2ByteArray(3586),CommonUtils.int2ByteArray(tempMax)));
            }
            if(HighData.getInstance().getValue(3589) != tempMin)
            {
                plcQuere.offer(modbusUtil.writeToOne(1,CommonUtils.int2ByteArray(3589),CommonUtils.int2ByteArray(tempMin)));
            }

            if(HighData.getInstance().setAdd_single_3586(tempMax))
            {
                hasChanged = true;
            }
            if( HighData.getInstance().setAdd_single_3589(tempMin))
            {
                hasChanged = true;
            }
        }
        if(hasChanged)
        {
            EventBus.getDefault().post(new DataBeanChangedEvent(0,0,0));
        }
    }


    private void copyToInt(int[] source,byte[] data)
    {
        for(int i = 0;i< 0x300;i++)
        {
            int dataIndex = i * 2+0x20 +4;
            source[i] = CommonUtils.byteArrayToInt16Temp(new byte[]{data[dataIndex], data[dataIndex + 1]});
        }


        int tempMax =  (CommonUtils.byteArrayToInt16Temp(new byte[]{data[30], data[31]}));
        int tempMin =  (CommonUtils.byteArrayToInt16Temp(new byte[]{data[32], data[33]}));

        boolean hasChanged = false;
        if(data[0] == 1)
        {
            Log.e("NEWNEWNEW","1 MAX:"+tempMax+" MIN:"+tempMin);
            if(HighData.getInstance().getValue(3584) != tempMax)
            {
                plcQuere.offer(modbusUtil.writeToOne(1,CommonUtils.int2ByteArray(3584),CommonUtils.int2ByteArray(tempMax)));
            }
            if(HighData.getInstance().getValue(3587) != tempMin)
            {
                plcQuere.offer(modbusUtil.writeToOne(1,CommonUtils.int2ByteArray(3587),CommonUtils.int2ByteArray(tempMin)));
            }

            if(HighData.getInstance().setAdd_single_3584(tempMax))
            {
                hasChanged = true;
            }
            if(HighData.getInstance().setAdd_single_3587(tempMin)){
                hasChanged = true;
            }
        }else if(data[0] == 2){
            Log.e("NEWNEWNEW","2 MAX:"+tempMax+" MIN:"+tempMin);
            //地址为2的温度
            if(HighData.getInstance().getValue(3585) != tempMax)
            {
                plcQuere.offer(modbusUtil.writeToOne(1,CommonUtils.int2ByteArray(3585),CommonUtils.int2ByteArray(tempMax)));
            }
            if(HighData.getInstance().getValue(3588) != tempMin)
            {
                plcQuere.offer(modbusUtil.writeToOne(1,CommonUtils.int2ByteArray(3588),CommonUtils.int2ByteArray(tempMin)));
            }

            if(HighData.getInstance().setAdd_single_3585(tempMax))
            {
                hasChanged = true;
            }
            if(HighData.getInstance().setAdd_single_3588(tempMin))
            {
                hasChanged = true;
            }
        }
        else if(data[0] == 3)
        {
            Log.e("NEWNEWNEW","3 MAX:"+tempMax+" MIN:"+tempMin);
            //地址为3的温度
            if(HighData.getInstance().getValue(3586) != tempMax)
            {
                plcQuere.offer(modbusUtil.writeToOne(1,CommonUtils.int2ByteArray(3586),CommonUtils.int2ByteArray(tempMax)));
            }
            if(HighData.getInstance().getValue(3589) != tempMin)
            {
                plcQuere.offer(modbusUtil.writeToOne(1,CommonUtils.int2ByteArray(3589),CommonUtils.int2ByteArray(tempMin)));
            }

            if(HighData.getInstance().setAdd_single_3586(tempMax))
            {
                hasChanged = true;
            }
            if( HighData.getInstance().setAdd_single_3589(tempMin))
            {
                hasChanged = true;
            }
        }
        if(hasChanged)
        {
            EventBus.getDefault().post(new DataBeanChangedEvent(0,0,0));
        }


    }

    private void drawImage(){
        new Thread(new Runnable() {
            @Override
            public void run() {
                //Random r = new Random();
                //float beginTemp = 38.0f;
                while(isRun){

                    /*
                    int current = 300;
                    int h1 = Integer.MIN_VALUE;
                    int h2 = Integer.MIN_VALUE;
                    int h3 = Integer.MIN_VALUE;
                    int l1 = Integer.MAX_VALUE;
                    int l2 = Integer.MAX_VALUE;
                    int l3 = Integer.MAX_VALUE;
                    int avg1 = 0;
                    int avg2 = 0;
                    int avg3 = 0;
                    for(int i = 0;i< 0x300;i++)
                    {
                        tempData1[i] = (byte)r.nextInt(10)+220;

                        if(h1 < tempData1[i])
                        {
                            h1 = tempData1[i];
                        }
                        if(l1 > tempData1[i])
                        {
                            l1 = tempData1[i];
                        }

                        tempData2[i] = (byte)r.nextInt(10)+220;

                        if(h2 < tempData2[i])
                        {
                            h2 = tempData2[i];
                        }
                        if(l2 > tempData2[i])
                        {
                            l2 = tempData2[i];
                        }

                        tempData3[i] = (byte) r.nextInt(10)+220;


                        if(h3 < tempData3[i])
                        {
                            h3 = tempData3[i];
                        }
                        if(l3 > tempData3[i])
                        {
                            l3 = tempData3[i];
                        }

                        if(avg1 == 0)
                        {
                            avg1 = tempData1[i];
                        }
                        else{
                            avg1 = (avg1 + tempData1[i]) /2;
                        }

                        if(avg2 == 0)
                        {
                            avg2 = tempData2[i];
                        }
                        else{
                            avg2 = (avg2 + tempData2[i]) /2;
                        }

                        if(avg3 == 0)
                        {
                            avg3 = tempData3[i];
                        }
                        else{
                            avg3 = (avg3 + tempData3[i]) /2;
                        }

//                        Log.d("SHOOTLEE_TETETE","1:"+tempData1[i]);
//                        Log.d("SHOOTLEE_TETETE","2:"+tempData2[i]);
//                        Log.d("SHOOTLEE_TETETE","3:"+tempData3[i]);
                      //  Log.d("SHOOTLEE_TETETE","当前值："+CommonUtils.byteArrayToInt16(new byte[]{tempData1[i],tempData1[i+1]}));

                    }




                    status.temp_3584 = r.nextInt(4) / 10 + beginTemp;
                    status.temp_3585 = r.nextInt(4) / 10 + beginTemp;
                    status.temp_3586 = r.nextInt(4) / 10 + beginTemp;
                    status.temp_3587 = r.nextInt(4) / 10 + beginTemp-2;
                    status.temp_3588 = r.nextInt(4) / 10 + beginTemp-2;
                    status.temp_3589 = r.nextInt(4) / 10 + beginTemp-2;

                    status.temp_avg_1 =  (status.temp_3584+status.temp_3587) / 2;
                    status.temp_avg_2 = (status.temp_3585+status.temp_3588) / 2;
                    status.temp_avg_3 = (status.temp_3586+status.temp_3589) / 2;

                     */



//                    plcQuere.offer(modbusUtil.writeToOne(1,CommonUtils.int2ByteArray(3584),CommonUtils.int2ByteArray(h1)));
//                    plcQuere.offer(modbusUtil.writeToOne(1,CommonUtils.int2ByteArray(3585),CommonUtils.int2ByteArray(h2)));
//                    plcQuere.offer(modbusUtil.writeToOne(1,CommonUtils.int2ByteArray(3586),CommonUtils.int2ByteArray(h3)));
//                    plcQuere.offer(modbusUtil.writeToOne(1,CommonUtils.int2ByteArray(3587),CommonUtils.int2ByteArray(l1)));
//                    plcQuere.offer(modbusUtil.writeToOne(1,CommonUtils.int2ByteArray(3588),CommonUtils.int2ByteArray(l2)));
//                    plcQuere.offer(modbusUtil.writeToOne(1,CommonUtils.int2ByteArray(3589),CommonUtils.int2ByteArray(l3)));
//
//                    HighData.getInstance().setAdd_single_3584(h1);
//                    HighData.getInstance().setAdd_single_3585(h2);
//                    HighData.getInstance().setAdd_single_3586(h3);
//                    HighData.getInstance().setAdd_single_3587(l1);
//                    HighData.getInstance().setAdd_single_3588(l2);
//                    HighData.getInstance().setAdd_single_3589(l3);



                    EventBus.getDefault().post(new DataBeanChangedEvent(0,0,0));
                    SystemClock.sleep(3000);
                    Bitmap bitmap1 =  TemperatureImageUtils.buildImage90ForIndex(tempData1,0);
                    EventBus.getDefault().post(new TemperatureDataEvent(bitmap1,0));
                    SystemClock.sleep(3000);
                    Bitmap bitmap2 =  TemperatureImageUtils.buildImage90ForIndex(tempData2,1);
                    EventBus.getDefault().post(new TemperatureDataEvent(bitmap2,1));
                    SystemClock.sleep(3000);
                    Bitmap bitmap3 =  TemperatureImageUtils.buildImage90ForIndex(tempData3,2);
                    EventBus.getDefault().post(new TemperatureDataEvent(bitmap3,2));

                    /*
                    SystemClock.sleep(10);
                    Bitmap bitmap1 =  TemperatureImageUtils.buildImage90ForIndex(tempData1,0);
                    //Bitmap bitmap1 =  TemperatureImageUtils.buildImage90(tempData1);
                    EventBus.getDefault().post(new TemperatureDataEvent(bitmap1,0));
                    SystemClock.sleep(10);
                    Bitmap bitmap2 =  TemperatureImageUtils.buildImage90ForIndex(tempData2,1);
                    //Bitmap bitmap2 =  TemperatureImageUtils.buildImage90(tempData2);
                    EventBus.getDefault().post(new TemperatureDataEvent(bitmap2,1));
                    SystemClock.sleep(10);
                    Bitmap bitmap3 =  TemperatureImageUtils.buildImage90ForIndex(tempData3,2);
                    //Bitmap bitmap3 =  TemperatureImageUtils.buildImage90(tempData3);
                    EventBus.getDefault().post(new TemperatureDataEvent(bitmap3,2));
                    SystemClock.sleep(10);
                    */


                }
            }
        }).start();

    }

}
